/**
 * Copyright (c) 2023, 2024 Sebastian Zarnekow and others.
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0.
 * 
 * SPDX-License-Identifier: EPL-2.0
 */
package org.eclipse.xtend.core.tests.compiler;

import org.eclipse.xtend2.lib.StringConcatenation;
import org.junit.Test;

@SuppressWarnings("all")
public class CompilerBug1005Test extends AbstractXtendCompilerTest {
  @Test
  public void testBug516321() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package com.acme");
    _builder.newLine();
    _builder.append("import java.util.function.Consumer");
    _builder.newLine();
    _builder.append("import static com.acme.Outer.E0.*");
    _builder.newLine();
    _builder.append("class Outer {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("static class C {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("def m(B<?> it) {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("child(E1.F) [");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("c(7)");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("]");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("enum E0 {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("c");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("enum E1 {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("F");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("static class A<T> {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("static class B<T> {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("def B<T> c(int i) {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("return this;");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("def <C> B<T> child(Consumer<B<C>> consumer) {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("return null;");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("def <C> B<T> child(A<C> child) {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("return null;");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("def <C> B<T> child(E1 e1, Consumer<B<C>> consumer) {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("return null;");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("package com.acme;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("import java.util.function.Consumer;");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@SuppressWarnings(\"all\")");
    _builder_1.newLine();
    _builder_1.append("public class Outer {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public static class C {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("public Outer.B<?> m(final Outer.B<?> it) {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("final Consumer<Outer.B<Outer.C>> _function = (Outer.B<Outer.C> it_1) -> {");
    _builder_1.newLine();
    _builder_1.append("        ");
    _builder_1.append("it_1.c(7);");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("};");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("return it.<Object>child(Outer.E1.F, _function);");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public enum E0 {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("c;");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public enum E1 {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("F;");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public static class A<T extends Object> {");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("public static class B<T extends Object> {");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("public Outer.B<T> c(final int i) {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("return this;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("public <C extends Object> Outer.B<T> child(final Consumer<Outer.B<Outer.C>> consumer) {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("return null;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("public <C extends Object> Outer.B<T> child(final Outer.A<Outer.C> child) {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("return null;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("public <C extends Object> Outer.B<T> child(final Outer.E1 e1, final Consumer<Outer.B<Outer.C>> consumer) {");
    _builder_1.newLine();
    _builder_1.append("      ");
    _builder_1.append("return null;");
    _builder_1.newLine();
    _builder_1.append("    ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("  ");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.assertCompilesTo(_builder, _builder_1);
  }
}
